package com.example.uploadfile.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
//@Slf4j
public class Hello {
    private static final Logger LOGGER = LoggerFactory.getLogger(Hello.class);

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping(value = "/hello")
    public String hello() {
        LOGGER.debug("debug");
        LOGGER.info("info");
        LOGGER.warn("warn");
        LOGGER.error("error");
        return "hello world...";
    }

    @GetMapping(value = "/hello2")
    public String hello2() {
        String url = "http://localhost:8081/upload-file/hello";
        return restTemplate.getForObject(url, String.class);
    }
}
